<template>
	<footer class="footer">
		<span class="todo-count">剩余<strong>{{theList}}</strong></span>
		<ul class="filters">
			<li>
				<a :class="{selected:selectType === 'all'}" 
				@click="changeType('all')"
				href="javascript:;">全部</a>
			</li>
			<li>
				<a :class="{selected:selectType === 'active'}" 
				@click="changeType('active')"
				href="javascript:;">未完成</a>
			</li>
			<li>
				<a :class="{selected:selectType === 'complete'}"
				@click="changeType('complete')"
				 href="javascript:;">已完成</a>
			</li>
		</ul>
		<button class="clear-completed" @click="del" v-show="showClear">清除已完成</button>
	</footer>
</template>

<script>
	export default {
		props:{
			arr:{
				type:Array,
				require:true
			}
		},
		data(){
			return{
				selectType:'all'
			}
		},
		computed:{
			theList(){
			return this.arr.filter(item => !item.isDone).length
			},
			showClear(){
			return	this.arr.some(item => item.isDone)
			}
		},
		methods:{
			del(){
				this.$emit('change')
			},
			changeType(type){
				this.selectType = type //切换高亮
				this.$emit('changeType',type)
			}
		}
	}
</script>
